<template>
  <div class="app-container">
    <a-title @clickPreview="preview" />
    <el-form
      ref="queryForm"
      :model="queryParams"
      :inline="true"
      label-width="100px"
    >
      <el-form-item label="项目名称" prop="name">
        <el-input
          v-model="queryParams.name"
          placeholder="请输入项目名称"
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="viewList"
        />
      </el-form-item>
      <el-form-item label="项目代码" prop="code">
        <el-input
          v-model="queryParams.code"
          placeholder="请输入项目代码"
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="viewList"
        />
      </el-form-item>
      <el-form-item label="项目负责人" prop="projectLeader" label-width="100px">
        <el-input
          v-model="queryParams.projectLeader"
          placeholder="请输入项目负责人"
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="viewList"
        />
      </el-form-item>
      <el-form-item
        label="是否分享"
        prop="isShare"
        label-width="100px"
      >
        <el-select
          v-model="queryParams.isShare"
          placeholder="请选择是否分享"
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="viewList"
        >
          <el-option label="不分享" value="0" />
          <el-option label="部分分享" value="2" />
          <el-option label="完整分享" value="1" />
        </el-select>
      </el-form-item>
      <el-form-item
        label="是否保密工程"
        prop="projectLeader"
        label-width="100px"
      >
        <el-select
          v-model="queryParams.isSecurity"
          placeholder="请选择是否保密工程"
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="viewList"
        >
          <el-option
            v-for="item in securityOptions"
            :key="item.dictValue"
            :label="item.dictLabel"
            :value="item.dictValue"
          />
        </el-select>
      </el-form-item>

      <el-form-item label="项目描述" prop="projectLeader" label-width="100px">
        <el-input
          v-model="queryParams.projectDesc"
          placeholder="请输入项目描述"
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="viewList"
        />
      </el-form-item>
      <el-form-item label="锁定状态" prop="projectLeader" label-width="100px">
        <el-select
          v-model="queryParams.lockStatus"
          placeholder="请选择锁定状态"
          clearable
          size="small"
          style="width: 240px"
          @keyup.enter.native="viewList"
        >
          <el-option
            v-for="item in lockOptions"
            :key="item.dictValue"
            :label="item.dictLabel"
            :value="item.dictValue"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="项目进展" prop="status">
        <el-select
          v-model="queryParams.status"
          placeholder="请选择项目进展"
          clearable
          size="small"
          style="width: 240px"
        >
          <el-option
            v-for="item in statusOptions"
            :key="item.dictValue"
            :label="item.dictLabel"
            :value="item.dictValue"
          />
        </el-select>
      </el-form-item>

      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="viewList"
          >查询</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="reset"
          >重置</el-button
        >
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          icon="el-icon-plus"
          size="mini"
          @click="handleNoShow()"
          >新增</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="primary"
          icon="el-icon-download"
          size="mini"
          @click="exportProjectShow()"
          >导出</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="primary"
          icon="el-icon-lock"
          size="mini"
          @click="lockOrUnlock('2')"
          >锁定</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="primary"
          icon="el-icon-unlock"
          size="mini"
          @click="lockOrUnlock('1')"
          >解锁</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="primary"
          icon="el-icon-refresh"
          size="mini"
          @click="handleHistory()"
          >历史操作记录</el-button
        >
      </el-col>
    </el-row>
    <div class="tablebox">
      <el-table
        stripe
        v-loading="loading"
        :data="tableData"
        style="width: 100%"
        :default-sort="{ prop: 'startDate', order: 'descending' }"
        @sort-change="tableSortChange"
        @selection-change="handleSelectionChange"
      >
        <el-table-column type="selection" width="55"> </el-table-column>
        <el-table-column
          label="项目名称"
          prop="name"
          align="left"
          :sort-orders="['ascending', 'descending']"
          sortable="custom"
          min-width="230"
        />
        <el-table-column
          label="项目代码"
          prop="code"
          align="center"
          :sort-orders="['ascending', 'descending']"
          sortable="custom"
        />
        <el-table-column
          label="项目负责人"
          prop="projectLeader"
          :sort-orders="['ascending', 'descending']"
          sortable="custom"
          width="110"
        />
        <el-table-column
          label="是否分享"
          prop="isShare"
          width="90"
        />
        <el-table-column
          label="是否保密工程"
          prop="isSecurity"
          :sort-orders="['ascending', 'descending']"
          sortable="custom"
          width="125"
        />
        <el-table-column
          label="项目描述"
          prop="projectDesc"
          :sort-orders="['ascending', 'descending']"
          sortable="custom"
          width="110"
          show-overflow-tooltip
        />
        <el-table-column
          label="是否锁定"
          prop="lockStatus"
          :sort-orders="['ascending', 'descending']"
          sortable="custom"
          align="center"
          width="110"
        />
        <el-table-column
          label="项目进展"
          prop="status"
          align="center"
          :sort-orders="['ascending', 'descending']"
          sortable="custom"
          width="140"
        >
        </el-table-column>
        <el-table-column label="操作" align="center">
          <template slot-scope="scope">
            <a @click="handleView(scope.$index, scope.row)">
              <i class="el-icon-view aicon"></i>预览
            </a>
            <a @click="handleEdit(scope.$index, scope.row)">
              <i class="el-icon-edit aicon"></i>编辑
            </a>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="viewList"
      />
    </div>
    <!-- 历史变更记录对话框 -->
    <el-dialog :title="historyTitle" :visible.sync="openHistory" width="80%">
      <el-form
        ref="queryHistoryForm"
        :model="queryHistoryParams"
        :inline="true"
        label-width="88px"
        @submit.native.prevent
      >
        <el-form-item label="项目名称" prop="projectName">
          <el-input
            v-model="queryHistoryParams.projectName"
            placeholder="操作人项目名称"
            clearable
            size="small"
            style="width: 240px"
            @keyup.enter.native="getHistoryList"
        /></el-form-item>
        <el-form-item label="项目代码" prop="projectCode">
          <el-input
            v-model="queryHistoryParams.projectCode"
            placeholder="操作人项目代码"
            clearable
            size="small"
            style="width: 240px"
            @keyup.enter.native="getHistoryList"
        /></el-form-item>
        <el-form-item label="项目负责人" prop="projectLeader">
          <el-input
            v-model="queryHistoryParams.projectLeader"
            placeholder="操作人项目负责人"
            clearable
            size="small"
            style="width: 240px"
            @keyup.enter.native="getHistoryList"
        /></el-form-item>
        <el-form-item label="操作人姓名" prop="operPerson">
          <el-input
            v-model="queryHistoryParams.operPerson"
            placeholder="操作人姓名"
            clearable
            size="small"
            style="width: 240px"
            @keyup.enter.native="getHistoryList"
        /></el-form-item>
        <el-form-item label="员工编号" prop="operPersonNo">
          <el-input
            v-model="queryHistoryParams.operPersonNo"
            placeholder="请输入员工编号"
            clearable
            size="small"
            style="width: 240px"
            @keyup.enter.native="getHistoryList"
          />
        </el-form-item>
        <el-form-item label="操作时间">
          <el-date-picker
            v-model="queryHistoryParams.historyDateRange"
            clearable
            size="small"
            style="width: 240px"
            type="daterange"
            value-format="yyyy-MM-dd"
            range-separator="-"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          />
        </el-form-item>
        <el-form-item label="字段名称" prop="fieldName">
          <el-input
            style="width: 240px"
            v-model="queryHistoryParams.fieldName"
            placeholder="请输入字段名称"
            clearable
            size="small"
            @keyup.enter.native="getHistoryList"
          />
        </el-form-item>
        <el-form-item label="原值" prop="initParams">
          <el-input
            style="width: 240px"
            v-model="queryHistoryParams.initParams"
            placeholder="请输入原值"
            clearable
            size="small"
            @keyup.enter.native="getHistoryList"
          />
        </el-form-item>
        <el-form-item label="现值" prop="newParams">
          <el-input
            style="width: 240px"
            v-model="queryHistoryParams.newParams"
            placeholder="请输入现值"
            clearable
            size="small"
            @keyup.enter.native="getHistoryList"
          />
        </el-form-item>
        <el-form-item>
          <el-button
            type="primary"
            icon="el-icon-search"
            size="mini"
            @click="getHistoryList"
            >查询</el-button
          >
          <el-button icon="el-icon-refresh" size="mini" @click="resetHistory"
            >重 置</el-button
          >
        </el-form-item>
      </el-form>

      <el-table
        v-loading="historyLoading"
        :data="historyList"
        :default-sort="{ prop: 'operTime', order: 'descending' }"
        @sort-change="historyTableSortChange"
      >
        <el-table-column
          label="项目名称"
          align="center"
          prop="projectName"
          width="120"
          :sort-orders="['ascending', 'descending']"
          sortable="custom"
        />
        <el-table-column
          label="项目代码"
          align="center"
          prop="projectCode"
          width="120"
          :sort-orders="['ascending', 'descending']"
          sortable="custom"
        />
        <el-table-column
          label="项目负责人"
          align="center"
          prop="projectLeader"
          width="120"
          :sort-orders="['ascending', 'descending']"
          sortable="custom"
        />
        <el-table-column
          label="操作人姓名"
          align="center"
          prop="operPerson"
          width="120"
          :sort-orders="['ascending', 'descending']"
          sortable="custom"
        />
        <el-table-column
          label="员工编号"
          align="center"
          prop="operPersonNo"
          width="100"
          :sort-orders="['ascending', 'descending']"
          sortable="custom"
        />
        <el-table-column
          label="操作时间"
          align="center"
          prop="operTime"
          width="100"
          :sort-orders="['ascending', 'descending']"
          sortable="custom"
        />
        <el-table-column
          label="字段名称"
          align="center"
          prop="fieldName"
          width="120"
          :sort-orders="['ascending', 'descending']"
          sortable="custom"
        />
        <el-table-column
          label="原值"
          align="center"
          prop="initParams"
          :sort-orders="['ascending', 'descending']"
          sortable="custom"
        />
        <el-table-column
          label="现值"
          align="center"
          prop="newParams"
          :sort-orders="['ascending', 'descending']"
          sortable="custom"
        />
      </el-table>
      <pagination
        v-show="totalHistory > 0"
        :total="totalHistory"
        :page.sync="queryHistoryParams.pageNum"
        :limit.sync="queryHistoryParams.pageSize"
        @pagination="getHistoryList"
      />
    </el-dialog>

    <!-- 预览 -->
    <el-dialog :visible.sync="openPreview" width="80%">
      <iframe
        :src="manualPreviewUrl"
        frameborder="0"
        width="100%"
        height="700px"
      ></iframe>
    </el-dialog>

    <project-edit
      :dialogVisible="dialogVisible"
      :projectId="projectId"
      @changedialogVisible="changedialogVisible"
      v-if="dialogVisible"
    ></project-edit>

    <!-- 未展示项目列表对话框 -->
    <el-dialog :title="noShowTitle" :visible.sync="openNoShow" width="80%">
      <el-form
        ref="queryNoShowForm"
        :model="queryNoShowParams"
        :inline="true"
        label-width="96px"
        @submit.native.prevent
      >
        <el-form-item label="项目名称" prop="name">
          <el-input
            v-model="queryNoShowParams.name"
            placeholder="请输入项目名称"
            clearable
            size="small"
            style="width: 200px"
            @keyup.enter.native="noShowViewList"
          />
        </el-form-item>
        <el-form-item label="项目代码" prop="code">
          <el-input
            v-model="queryNoShowParams.code"
            placeholder="请输入项目代码"
            clearable
            size="small"
            style="width: 200px"
            @keyup.enter.native="noShowViewList"
          />
        </el-form-item>
        <el-form-item label="项目进展" prop="status">
          <el-select
            v-model="queryNoShowParams.status"
            placeholder="请选择项目进展"
            clearable
            size="small"
            style="width: 200px"
          >
            <el-option
              v-for="item in statusOptions"
              :key="item.dictValue"
              :label="item.dictLabel"
              :value="item.dictValue"
            />
          </el-select>
        </el-form-item>
        
        <el-form-item label="项目执行部门" prop="executeDept">
          <el-input
            v-model="queryNoShowParams.executeDept"
            placeholder="请输入项目执行部门"
            clearable
            size="small"
            style="width: 200px"
            @keyup.enter.native="noShowViewList"
          />
        </el-form-item>
        <!--<el-form-item label="开始服务日期" label-width="100px">
        <el-date-picker
          v-model="noShowDateRange"
          size="small"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        />
      </el-form-item>-->
        <el-form-item label="委托单位" prop="party">
          <el-input
            v-model="queryNoShowParams.party"
            placeholder="请输入委托单位"
            clearable
            size="small"
            style="width: 200px"
            @keyup.enter.native="noShowViewList"
          />
        </el-form-item>
        <el-form-item
          label="项目负责人"
          prop="projectLeaderName"
        >
          <el-input
            v-model="queryNoShowParams.projectLeaderName"
            placeholder="请输入项目负责人"
            clearable
            size="small"
            style="width: 200px"
            @keyup.enter.native="noShowViewList"
          />
        </el-form-item>
        <!--<el-form-item label="结项状态" prop="closureSituationNew">
          <el-input
            v-model="queryNoShowParams.closureSituationNew"
            placeholder="请输入结项状态"
            clearable
            size="small"
            style="width: 240px"
            @keyup.enter.native="noShowViewList"
          />
        </el-form-item>-->
        <el-form-item>
          <el-button
            type="primary"
            icon="el-icon-search"
            size="mini"
            @click="noShowViewList"
            >查询</el-button
          >
          <el-button icon="el-icon-refresh" size="mini" @click="resetNoShow"
            >重 置</el-button
          >
        </el-form-item>
      </el-form>

      <el-table
        v-loading="noShowLoading"
        :data="noShowList"
        :default-sort="{ prop: 'operTime', order: 'descending' }"
        @sort-change="noShowTableSortChange"
        @selection-change="handleNoShowSelectionChange"
      >
        <!--<el-table-column type="selection" width="55"> </el-table-column>-->
        <el-table-column
          label="项目名称"
          prop="name"
          align="left"
          :sort-orders="['ascending', 'descending']"
          sortable="custom"
          min-width="230"
        />
        <el-table-column
          label="项目代码"
          prop="code"
          align="center"
          :sort-orders="['ascending', 'descending']"
          sortable="custom"
        />
        <el-table-column
          label="项目进展"
          prop="status"
          align="center"
          :sort-orders="['ascending', 'descending']"
          sortable="custom"
          width="140"
        >
          <template slot-scope="scope">
            <el-tag :type="scope.row.statusType" disable-transitions>{{
              scope.row.statusText
            }}</el-tag>
          </template>
        </el-table-column>
        <!-- <el-table-column
          label="结项状态"
          align="center"
          prop="closureSituationNew"
          :sort-orders="['ascending', 'descending']"
          sortable="custom"
          width="140"
        >
        </el-table-column>-->
        <!--<el-table-column
          label="开始服务日期"
          prop="startDate"
          :sort-orders="['ascending', 'descending']"
          sortable="custom"
          width="140"
        >
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.startDate,'{y}-{m}-{d} ') }}</span>
          </template>
        </el-table-column>-->
        <el-table-column
          label="项目执行部门"
          prop="executeDept"
          :sort-orders="['ascending', 'descending']"
          sortable="custom"
        />
        <el-table-column
          label="委托单位"
          align="left"
          prop="party"
          :sort-orders="['ascending', 'descending']"
          sortable="custom"
        />
        <el-table-column
          label="项目负责人"
          prop="projectLeaderName"
          :sort-orders="['ascending', 'descending']"
          sortable="custom"
          width="110"
        />
        <el-table-column label="操作" align="center">
          <template slot-scope="scope">
            <a @click="handleEdit(scope.$index, scope.row)">
              <i class="el-icon-edit aicon"></i>编辑
            </a>
          </template>
        </el-table-column>
      </el-table>
      
      <pagination
        v-show="totalNoShow > 0"
        :total="totalNoShow"
        :page.sync="queryNoShowParams.pageNum"
        :limit.sync="queryNoShowParams.pageSize"
        @pagination="noShowViewList"
      />
      <span slot="footer" class="dialog-footer">
        <el-button @click="openNoShow = false">取 消</el-button>
        <!--<el-button type="primary" @click="addShowProject()">确 定</el-button>-->
      </span>
    </el-dialog>
  </div>
</template>
<script>
import {
  listProjectShow,
  lockOrUnlock,
  exportProjectShow,
  getProjectShowDetail,
  noShowList,
  updateProject,
} from "@/api/projectShowLibrary/projectShowLibrary";
import {
  listOper,
  getOper,
  delOper,
  addOper,
  updateOper,
  exportOper,
} from "@/api/projectWorkbench/projectList/oper";
import aTitle from "@/components/Title";
import projectEdit from "@/components/projectEdit/projectEdit";
import { mapGetters } from "vuex";
export default {
  name: "ProjectGlance",
  components: { aTitle, projectEdit },
  computed: {
    ...mapGetters(["permission_routes"]),
  },
  data() {
    return {
      noShowList: [],
      noShowLoading: false,
      dialogVisible: false,
      projectId: "",
      guids: [],
      noShowGuids: [],
      historyLoading: false,
      historyList: [],
      totalHistory: 0,
      totalNoShow: 0,
      openHistory: false,
      historyTitle: "",
      noShowTitle: "",
      openNoShow: false,
      // 查询参数
      queryNoShowParams: {
        pageNum: 1,
        pageSize: 10,
        party: undefined,
        name: undefined,
        projectLeader: undefined,
        status: undefined,
        projectLeaderName: undefined,
        code: undefined,
        executeDept:undefined
      },
      queryHistoryParams: {
        pageNum: 1,
        pageSize: 10,
        projectName: undefined,
        projectCode: undefined,
        projectLeader: undefined,
        operPerson: undefined,
        operPersonNo: undefined,
        operTime: undefined,
        initParams: undefined,
        newParams: undefined,
        projectId: undefined,
        fieldName: undefined,
        historyDateRange: [],
      },
      manualPreviewUrl: null,
      openPreview: false,
      loading: true,
      total: 0,
      securityOptions: [
        {
          dictValue: "0",
          dictLabel: "否",
        },
        {
          dictValue: "1",
          dictLabel: "是",
        },
      ],
      lockOptions: [
        {
          dictValue: "1",
          dictLabel: "正常",
        },
        {
          dictValue: "2",
          dictLabel: "锁定",
        },
      ],
      projectRoutes: [],
      statusOptions: [],
      tableData: [],
      dateRange: [],
      noShowDateRange: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        name: undefined,
        code: undefined,
        projectLeader: undefined,
        isSecurity: undefined,
        projectDesc: undefined,
        lockStatus: undefined,
        status: undefined,
      },
    };
  },
  created() {
    this.queryParams.status =
      sessionStorage.getItem("projectStatus") || undefined;
    if (sessionStorage.getItem("projectStatus") === "undefined") {
      this.queryParams.status = undefined;
    }
    this.viewList();
    this.getDicts("sys_project_status").then((response) => {
      this.statusOptions = response.data;
    });
  },
  beforeRouteLeave(to, from, next) {
    sessionStorage.removeItem("projectStatus");
    next();
  },
  methods: {
    changedialogVisible(val) {
      this.dialogVisible = val;
      if(!val){
        this.viewList();
      }
    },
    preview() {
      this.openPreview = true;
      this.manualPreviewUrl = `${this.previewUrl}${encodeURIComponent(
        `${this.operationManual}项目工作台/业务系统操作说明-项目工作台.xlsx`
      )}&name=${encodeURIComponent("业务系统操作说明-项目工作台.xlsx")}`;
    },
    viewList() {
      this.loading = true;
      //查询项目列表
      listProjectShow(this.addDateRange(this.queryParams, this.dateRange)).then(
        (res) => {
          if (res.code === 200) {
            this.total = res.total;
            this.tableData = res.rows.map((item) => {
              /*if (item.isvalid === "0") {
                item.statusText = "作废";
                item.statusType = "danger";
              } else {
                if (item.status === "0") {
                  item.statusText = "筹备";
                  item.statusType = "";
                } else if (item.status === "1") {
                  item.statusText = "进行中";
                  item.statusType = "info";
                } else if (item.status === "2") {
                  item.statusText = "成果交付";
                  item.statusType = "success";
                } else if (item.status === "3") {
                  item.statusText = "项目完成";
                  item.statusType = "success";
                } else if (item.status === "4") {
                  item.statusText = "项目暂停";
                  item.statusType = "danger";
                } else if (item.status === "5") {
                  item.statusText = "项目终止";
                  item.statusType = "warning";
                } else if (item.status === "6") {
                  item.statusText = "项目作废";
                  item.statusType = "danger";
                }
              }*/
              return item;
            });
            this.loading = false;
          }
        }
      );
    },
    reset() {
      this.queryParams.pageNum = 1;
      this.queryParams.pageSize = 20;
      this.queryParams.name = undefined;
      this.queryParams.code = undefined;
      this.queryParams.projectLeader = undefined;
      this.queryParams.isSecurity = undefined;
      this.queryParams.projectDesc = undefined;
      this.queryParams.lockStatus = undefined;
      this.queryParams.status = undefined;
      this.viewList();
    },
    handleView(index, row) {
      let routeUrl = this.$router.resolve({
        path: "/projectShowDetailPage",
        query: { guid: row.guid },
      });
      window.open(routeUrl.href, "_blank");
    },
    handleEdit(index, row) {
      var $this = this;
      $this.projectId = row.guid;
      $this.dialogVisible = true;
      $this.openNoShow=false;
    },
    tableSortChange(column) {
      this.queryParams.pageNum = 1;
      if (column.order === "descending") {
        this.queryParams.sortBy = column.prop;
        this.queryParams.order = "desc";
      } else {
        this.queryParams.sortBy = column.prop;
        this.queryParams.order = "asc";
      }
      this.viewList();
    },
    /** 项目操作历史记录 */
    handleHistory() {
      this.resetHistory();
      this.openHistory = true;
      this.historyTitle = "项目操作历史记录";
      this.getHistoryList();
    },
    resetHistory() {
      this.queryHistoryForm = {
        nickName: undefined,
      };
      this.queryHistoryParams.historyDateRange = [];
      this.resetForm("queryHistoryForm");
      this.getHistoryList();
    } /** 查询项目操作历史记录列表 */,
    getHistoryList() {
      this.historyLoading = true;
      let reqPrams = {
        operPerson: this.queryHistoryParams.operPerson,
        operPersonNo: this.queryHistoryParams.operPersonNo,
        initParams: this.queryHistoryParams.initParams,
        newParams: this.queryHistoryParams.newParams,
        //projectId: this.$route.params.id,
        fieldName: this.queryHistoryParams.fieldName,
        sortBy: this.queryHistoryParams.sortBy,
        order: this.queryHistoryParams.order,
        pageNum: this.queryHistoryParams.pageNum,
        pageSize: this.queryHistoryParams.pageSize,
      };

      if (this.queryHistoryParams.historyDateRange) {
        reqPrams.beginTimeStart = this.queryHistoryParams.historyDateRange[0];
        reqPrams.endTimeEnd = this.queryHistoryParams.historyDateRange[1];
      }

      listOper(reqPrams).then((response) => {
        this.historyList = response.rows;
        if (this.historyList) {
          var items = this.historyList;
          items.forEach((item) => {
            item.operTime = this.renderTime(item.operTime);
          });
        }
        this.totalHistory = response.total;
        this.historyLoading = false;
      });
    },
    renderTime(date) {
      var dateee = new Date(date).toJSON();
      return new Date(+new Date(dateee) + 8 * 3600 * 1000)
        .toISOString()
        .replace(/T/g, " ")
        .replace(/\.[\d]{3}Z/, "");
    },
    historyTableSortChange(column) {
      this.queryHistoryParams.pageNum = 1;
      if (column.order === "descending") {
        this.queryHistoryParams.sortBy = column.prop;
        this.queryHistoryParams.order = "desc";
      } else {
        this.queryHistoryParams.sortBy = column.prop;
        this.queryHistoryParams.order = "asc";
      }
      this.getHistoryList();
    },
    handleSelectionChange(selection) {
      this.guids = selection.map((item) => item.guid);
    },
    handleNoShowSelectionChange(selection) {
      this.noShowGuids = selection.map((item) => item.guid);
    },
    lockOrUnlock(flag) {
      var $this = this;
      if (!this.guids) {
        this.msgError("请选择需要操作的数据！");
        return;
      }
      var reqParams = {
        guid: this.guids.join(","),
        lockStatus: flag,
      };

      lockOrUnlock(reqParams).then((res) => {
        if (res.code === 200) {
          $this.guids = [];
          $this.viewList();
          $this.msgSuccess(res.msg);
        }
      });
    },
    exportProjectShow() {
      debugger;
      var $this = this;

      this.$confirm("是否确认导出所有符合条件的项目展示库数据项?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(function () {
          exportProjectShow(
            $this.addDateRange($this.queryParams, $this.dateRange)
          ).then((res) => {
            if (res.code === 200) {
              $this.download(res.msg);
            }
          });
        })
        .catch(function () {});
    },
    noShowViewList() {
      this.noShowLoading = true;
      noShowList(
        this.addDateRange(this.queryNoShowParams, this.noShowDateRange)
      ).then((res) => {
        if (res.code === 200) {
          this.totalNoShow = res.total;
          this.noShowList = res.rows.map((item) => {
            
              if (item.status === "0") {
                item.statusText = "筹备";
                item.statusType = "";
              } else if (item.status === "1") {
                item.statusText = "进行中";
                item.statusType = "info";
              } else if (item.status === "2") {
                item.statusText = "成果交付";
                item.statusType = "success";
              } else if (item.status === "3") {
                item.statusText = "项目完成";
                item.statusType = "success";
              } else if (item.status === "4") {
                item.statusText = "项目暂停";
                item.statusType = "danger";
              } else if (item.status === "5") {
                item.statusText = "项目终止";
                item.statusType = "warning";
              } else if (item.status === "6") {
                item.statusText = "项目作废";
                item.statusType = "danger";
              }
            return item;
          });
          this.noShowLoading = false;
        }
      });
    },
    resetNoShow() {
      this.queryNoShowForm = {};
      this.resetForm("queryNoShowForm");
      this.noShowViewList();
    },
    noShowTableSortChange(column) {
      this.queryNoShowParams.pageNum = 1;
      if (column.order === "descending") {
        this.queryNoShowParams.sortBy = column.prop;
        this.queryNoShowParams.order = "desc";
      } else {
        this.queryNoShowParams.sortBy = column.prop;
        this.queryNoShowParams.order = "asc";
      }
      this.noShowViewList();
    },
    handleNoShow() {
      this.resetNoShow();
      this.openNoShow = true;
      this.noShowTitle = "未展示项目清单";
      this.noShowViewList();
    },
    addShowProject() {
      updateProject(this.noShowGuids).then((res) => {
        if (res.code === 200) {
          this.msgSuccess("新增展示项目成功！");
          this.noShowViewList();
          this.viewList();
          //this.openNoShow = true;
        }
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.tablebox {
  height: 100%;
}
/deep/.el-table .cell {
  font-family: PingFangSC-Regular;
  color: rgba(0, 0, 0, 0.85);
  letter-spacing: 0;
  // text-align: center;
  a {
    font-family: PingFangSC-Regular;
    font-size: 14px;
    color: #1890ff;
    letter-spacing: 0;
    text-align: right;
    line-height: 14px;
    margin: 0 10px;
  }
}
// /deep/.el-table_1_column_4{
//   text-align: center;
// }

.tipTag {
  height: 40px;
  line-height: 40px;
  margin-top: -10px;
}
</style>
